function lovelygalleryInit(P){
    var scripts = document.getElementsByTagName("script");
    var jsFolder = "";
    for (var i= 0; i< scripts.length; i++)
    {
        if( scripts[i].src && scripts[i].src.match(/lovelygallery\.js/i))
            jsFolder = scripts[i].src.substr(0, scripts[i].src.lastIndexOf("/") + 1);
    }
    var win_width = $(window).width();
    
    delete P['navstyle'];
    var S = P.S == 1 ? {
        _navpadding: 6,
        _navbackgroundcolor: "",
        navfontsize: 0
    } : P.S == 2 ? {
        navmargin: -34,
        navwidth: 25,
        navheight: 24,
        navspacing: 6,
        navfontcolor: 'rgba(255,255,255,0.5)',
        navcolor: 'rgba(0,0,0,0.3)',
        navhighlightcolor: '#000',
        navfonthighlightcolor: '#fff',
        navbuttonshowbgimage: false,
        navfontsize: 14
    } : {
        navmargin: -90,
        navwidth: 110,
        navheight: 60,
        navspacing: 20,
    	navstyle: 'thumbnails'
    }
    P = $.extend({
        jsfolder:jsFolder,
        width: P.width,
        height: P.height,
        
        previewmode: false,
        isresponsive: false,
        autoplay: true,
        pauseonmouseover: true,
        slideinterval: 5000,
        randomplay: false,
        loop: 0,
        skinsfoldername: 'bg',
        showtimer: true,
        timerposition: 'bottom',
        timercolor: '#ffffff',
        timeropacity: 0.6,
        timerheight: 2,
        autoplayvideo: false,
        playvideoimage: 'playvideo-64-64-0.png',
        playvideoimagewidth: 64,
        playvideoimageheight: 64,
        enabletouchswipe: true,
        border: 0,
        bordercolor: '#ffffff',
        borderradius: 0,
        showshadow: false,
        shadowsize: 5,
        shadowcolor: '#aaaaaa',
        showbottomshadow: true,
        bottomshadowimage: 'shd.png',
        bottomshadowimagewidth: 100,
        _bottomshadowimageheight: 17,
        bottomshadowimagetop: 100,
        showbackgroundimage: false,
        backgroundimage: 'background.png',
        backgroundimagewidth: 120,
        backgroundimagetop: -10,
        
        arrowstyle: 'mouseover',
        arrowimage: 'arrows_white_new3.png',
        arrowwidth: 50,
        arrowheight: 70,
        arrowmargin: 370,
        arrowhideonmouseleave: 1000,
        arrowtop: 48,

        showribbon: false,
        ribbonimage: 'ribbon_topleft-0.png',
        ribbonposition: 'topleft',
        ribbonimagex: -11,
        ribbonimagey: -11,
        textstyle: 'static',
        textpositionstatic: 'bottom',
        textautohide: false,
        textpositionmarginstatic: 0,
        textpositiondynamic: 'topleft,topright,bottomleft,bottomright',
        textpositionmarginleft: 24,
        textpositionmarginright: 24,
        textpositionmargintop: 24,
        textpositionmarginbottom: 24,
        texteffect: 'slide',
        texteffecteasing: 'easeOutCubic',
        texteffectduration: 600,
        addfonts: true,
        fonts: "Inder",
        textcss: 'display:block; padding:12px; text-align:left;',
        textbgcss: 'display:block; position:absolute; top:0px; left:0px; width:100%; height:100%; background-color:#333333; opacity:0.6; filter:alpha(opacity=60);',
        titlecss: 'display:block; position:relative; font:bold 14px Inder,Arial,Tahoma,Helvetica,sans-serif; color:#fff;',
        descriptioncss: 'display:block; position:relative; font:12px Anaheim,Arial,Tahoma,Helvetica,sans-serif; color:#fff;',
        shownumbering: false,
        numberingformat: "%NUM/%TOTAL ",
        
        navstyle: 'numbering',
        navswitchonmouseover: false,
        navdirection: 'horizontal',
        navposition: 'bottom',
        navmargin: -26,
        navwidth: 14,
        navheight: 14,
        navspacing: 5,
        navshowpreview: false,
        navpreviewposition: 'top',
        navpreviewarrowimage: 'preview-arrow.png',
        navpreviewarrowwidth: 20,
        navpreviewarrowheight: 10,
        navpreviewwidth: 120,
        navpreviewheight: 60,
        navpreviewborder: 8,
        navpreviewbordercolor: '#ffff00',
        navimage: 'bullets.png',
        navradius: 0,
        navcolor: '',
        navhighlightcolor: '',
        navfont: 'Lucida Console, Arial',
        navfontcolor: '#666666',
        navfonthighlightcolor: '#666666',
        navfontsize: 12,
        navbuttonshowbgimage: true,
        navbuttonbgimage: 'navbuttonbgimage.png',
        navshowbuttons: false,
        navbuttonradius: 2,
        navbuttoncolor: '#999999',
        navbuttonhighlightcolor: '#333333',
        navshowplaypause: true,
        navshowarrow: true,
        navplaypauseimage: 'nav-play-pause.png',
        navarrowimage: 'nav-arrows.png',
        navshowplaypausestandalone: false,
        navshowplaypausestandaloneautohide: false,
        navshowplaypausestandaloneposition: 'bottomright',
        navshowplaypausestandalonemarginx: 24,
        navshowplaypausestandalonemarginy: 24,
        navshowplaypausestandalonewidth: 32,
        navshowplaypausestandaloneheight: 32,
        navopacity: 0.7,
        navborder: 1,
        navbordercolor: '#ccc',
        navshowfeaturedarrow: false,
        navfeaturedarrowimage: 'featured-arrow.png',
        navfeaturedarrowimagewidth: 20,
        navfeaturedarrowimageheight: 10,
        navthumbstyle: 'imageonly',
        navthumbtitleheight: 20,
        navthumbtitlewidth: 120,
        navthumbtitlecss: 'display:block;position:relative;padding:2px 4px;text-align:left;font:bold 14px Arial,Helvetica,sans-serif;color:#333;',
        navthumbtitlehovercss: 'text-decoration:underline;',
        navthumbdescriptioncss: 'display:block;position:relative;padding:2px 4px;text-align:left;font:normal 12px Arial,Helvetica,sans-serif;color:#333;',
        navthumbnavigationstyle: 'arrow',
        navthumbnavigationarrowimage: 'carousel-arrows-32-32-0.png',
        navthumbnavigationarrowimagewidth: 32,
        navthumbnavigationarrowimageheight: 32,
        navshowplayvideo: true,
        navplayvideoimage: 'play-32-32-0.png',
        
        transitiononfirstslide: false,
        transition:"slide,crossfade,threedhorizontal,slice,fade,blocks,blinds,shuffle,threed",
        transitionduration: 1000,
        transitioneasing: 'easeOutQuad',
        slide: {
            duration:win_width,
            easing:"easeOutCubic",
            checked:true
        },
        crossfade: {
            duration:win_width,
            easing:"easeOutCubic",
            checked:true
        },
        threedhorizontal: {
            checked:true,
            bgcolor:"#222222",
            perspective:win_width,
            slicecount:1,
            duration:1500,
            easing:"easeOutCubic",
            fallback:"slice",
            scatter:5,
            perspectiveorigin:"bottom"
        },
        slice: {
            duration:1500,
            easing:"easeOutCubic",
            checked:true,
            effects:"up,down,updown",
            slicecount:10
        },
        fade: {
            duration:win_width,
            easing:"easeOutCubic",
            checked:true
        },
        blocks: {
            columncount:5,
            checked:true,
            rowcount:5,
            effects:"topleft,bottomright,top,bottom,random",
            duration:1500,
            easing:"easeOutCubic"
        },
        blinds: {
            duration:2000,
            easing:"easeOutCubic",
            checked:true,
            slicecount:3
        },
        shuffle: {
            duration:1500,
            easing:"easeOutCubic",
            columncount:5,
            checked:true,
            rowcount:5
        },
        threed: {
            checked:true,
            bgcolor:"#222222",
            perspective:win_width,
            slicecount:5,
            duration:1500,
            easing:"easeOutCubic",
            fallback:"slice",
            scatter:5,
            perspectiveorigin:"right"
        }
    }, S, P);
    jQuery(P.id).html5zoo(P);
}